package com.tjsinfo.tjsoa.workplan.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.workplan.bo.IWorkPlanMainBo;
import com.tjsinfo.tjsoa.workplan.vo.WorkPlanMain;

public class AddWorkPlanSituAction extends Action{

	private IWorkPlanMainBo workPlanMainBo;
	/**
	 * @return the workPlanMainBo
	 */
	public IWorkPlanMainBo getWorkPlanMainBo() {
		return workPlanMainBo;
	}
	/**
	 * @param workPlanMainBo the workPlanMainBo to set
	 */
	public void setWorkPlanMainBo(IWorkPlanMainBo workPlanMainBo) {
		this.workPlanMainBo = workPlanMainBo;
	}
	/* (non-Javadoc)
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String value = request.getParameter("contest");
		String id = request.getParameter("id") ;
		if (workPlanMainBo.addWorkPlanMainCompleteContent(value,id)) {
			//WorkPlanMain workPlanMain = workPlanMainBo.selectByID(id);
			//workPlanMain.setStart(3);
			//workPlanMainBo.update(id, workPlanMain.getTjsUserid(), workPlanMain.getTime(), workPlanMain.getType(), workPlanMain.getContent(), workPlanMain.getCompleteContent(), workPlanMain.getYear(), `, start)
			 WorkPlanMain workPlanMain = workPlanMainBo.selectByID(id);
			 String type = workPlanMain.getType();
			 if("D".equals(type))
				{
				 	request.setAttribute("linkurl", "tjsinfo/tjsoa/workplan/workPlanDateModle.do");
				 	request.setAttribute("message", "workplan.message.situ");
					return mapping.findForward("success");
				}
				else if("W".equals(type))
				{
					request.setAttribute("linkurl", "tjsinfo/tjsoa/workplan/workPlanWeekModle.do");
					request.setAttribute("message", "workplan.message.situ");
					return mapping.findForward("success");
				}
				else if("M".equals(type))
				{
					request.setAttribute("linkurl", "tjsinfo/tjsoa/workplan/workPlanMonthModle.do");
					request.setAttribute("message", "workplan.message.situ");
					return mapping.findForward("success");
				}
				else if("Q".equals(type))
				{
					request.setAttribute("linkurl", "tjsinfo/tjsoa/workplan/workPlanJiDuModle.do");
					request.setAttribute("message", "workplan.message.situ");
					return mapping.findForward("success");
					
				}
				else if("H".equals(type))
				{
					request.setAttribute("linkurl", "tjsinfo/tjsoa/workplan/workPlanHalfYearModle.do");
					request.setAttribute("message", "workplan.message.situ");
					return mapping.findForward("success");
				}
				else if("Y".equals(type))
				{
					request.setAttribute("linkurl", "tjsinfo/tjsoa/workplan/workPlanYearModle.do");
					request.setAttribute("message", "workplan.message.situ");
					return mapping.findForward("success");
				}
				
			 request.setAttribute("linkurl", "tjsinfo/tjsoa/workplan/workPlanlistmode.do");
				request.setAttribute("message", "workplan.message.situ");
				return mapping.findForward("success");
		} else {
			return mapping.findForward("error");
		}
		
	}
	
}
